package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.Sign;
import cn.wolfcode.trip.base.service.ISignService;
import cn.wolfcode.trip.base.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("signs")
public class SignController {

    @Autowired
    private ISignService signService;
    @GetMapping
    public Sign get(Long userId){
        return signService.selectBuUserId(userId);
    }

    @PutMapping("{user.id}")
    public JsonResult save(Sign sign){
        JsonResult jsonResult=new JsonResult();
        try {
            sign.setCreateTime(new Date());
            signService.save(sign);
        }catch (Exception e){
            e.printStackTrace();
            jsonResult.mark(e.getMessage());
        }
        return jsonResult;
    }
}
